<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.3.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/myblog/images/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/myblog/images/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/myblog/images/favicon-16x16.png">
  <link rel="mask-icon" href="/myblog/images/logo.svg" color="#222">

<link rel="stylesheet" href="/myblog/css/main.css">

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Monda:300,300italic,400,400italic,700,700italic%7CRoboto+Slab:300,300italic,400,400italic,700,700italic%7CNoto+Serif+SC:300,300italic,400,400italic,700,700italic%7CAmita:300,300italic,400,400italic,700,700italic%7CMontserrat:300,300italic,400,400italic,700,700italic%7CPT+Mono:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha256-AbA177XfpSnFEvgpYu1jMygiLabzPCJCRIBtR5jGc0k=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"wang-chen1119.gitee.io","root":"/myblog/","images":"/myblog/images","scheme":"Pisces","darkmode":false,"version":"8.13.1","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":false,"style":null},"bookmark":{"enable":true,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/myblog/js/config.js"></script>

    <meta name="description" content="进程1.为什么要引入进程 为了使程序在多道程序环境下能够并发执行，并对并发执行的程序加以控制和描述。 2. 进程的定义">
<meta property="og:type" content="blog">
<meta property="og:title" content="进程与程序">
<meta property="og:url" content="http://wang-chen1119.gitee.io/myblog/2022/10/28/%E8%BF%9B%E7%A8%8B%E4%B8%8E%E7%A8%8B%E5%BA%8F/index.html">
<meta property="og:site_name" content="Yorn&#39;s Notes">
<meta property="og:description" content="进程1.为什么要引入进程 为了使程序在多道程序环境下能够并发执行，并对并发执行的程序加以控制和描述。 2. 进程的定义">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://image-1305623006.cos.ap-nanjing.myqcloud.com/img/202210281356812.png">
<meta property="og:image" content="https://image-1305623006.cos.ap-nanjing.myqcloud.com/img/202210281356799.png">
<meta property="og:image" content="https://image-1305623006.cos.ap-nanjing.myqcloud.com/img/202210281356927.png">
<meta property="og:image" content="https://image-1305623006.cos.ap-nanjing.myqcloud.com/img/202210281356778.png">
<meta property="article:published_time" content="2022-10-28T05:57:30.712Z">
<meta property="article:modified_time" content="2022-10-28T06:21:30.317Z">
<meta property="article:author" content="yorn">
<meta property="article:tag" content="操作系统">
<meta property="article:tag" content="面经">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://image-1305623006.cos.ap-nanjing.myqcloud.com/img/202210281356812.png">


<link rel="canonical" href="http://wang-chen1119.gitee.io/myblog/2022/10/28/%E8%BF%9B%E7%A8%8B%E4%B8%8E%E7%A8%8B%E5%BA%8F/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://wang-chen1119.gitee.io/myblog/2022/10/28/%E8%BF%9B%E7%A8%8B%E4%B8%8E%E7%A8%8B%E5%BA%8F/","path":"2022/10/28/进程与程序/","title":"进程与程序"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>进程与程序 | Yorn's Notes</title>
  






  <noscript>
    <link rel="stylesheet" href="/myblog/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/myblog/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">Yorn's Notes</p>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-首页"><a href="/myblog/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-关于"><a href="/myblog/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li><li class="menu-item menu-item-标签"><a href="/myblog/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-分类"><a href="/myblog/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li>
  </ul>
</nav>




</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E8%BF%9B%E7%A8%8B"><span class="nav-number">1.</span> <span class="nav-text">进程</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E5%BC%95%E5%85%A5%E8%BF%9B%E7%A8%8B"><span class="nav-number">1.0.1.</span> <span class="nav-text">1.为什么要引入进程</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-%E8%BF%9B%E7%A8%8B%E7%9A%84%E5%AE%9A%E4%B9%89"><span class="nav-number">1.0.2.</span> <span class="nav-text">2. 进程的定义</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-%E7%A8%8B%E5%BA%8F%E5%92%8C%E8%BF%9B%E7%A8%8B%E7%9A%84%E5%8C%BA%E5%88%AB%E4%B8%8E%E8%81%94%E7%B3%BB"><span class="nav-number">1.0.3.</span> <span class="nav-text">3.程序和进程的区别与联系</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-%E8%BF%9B%E7%A8%8B%E7%9A%84%E7%89%B9%E5%BE%81"><span class="nav-number">1.0.4.</span> <span class="nav-text">4. 进程的特征</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-%E8%BF%9B%E7%A8%8B%E7%9A%84%E5%9F%BA%E6%9C%AC%E7%8A%B6%E6%80%81%E5%92%8C%E8%BD%AC%E6%8D%A2"><span class="nav-number">1.0.5.</span> <span class="nav-text">5. 进程的基本状态和转换</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%BF%9B%E7%A8%8B%E7%9A%84%E4%B8%89%E7%A7%8D%E7%8A%B6%E6%80%81"><span class="nav-number">1.0.5.1.</span> <span class="nav-text">进程的三种状态</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%B8%89%E7%A7%8D%E7%8A%B6%E6%80%81%E7%9A%84%E8%BD%AC%E6%8D%A2"><span class="nav-number">1.0.5.2.</span> <span class="nav-text">三种状态的转换</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%BF%9B%E7%A8%8B%E7%9A%84%E6%8C%82%E8%B5%B7%E7%8A%B6%E6%80%81"><span class="nav-number">1.0.5.3.</span> <span class="nav-text">进程的挂起状态</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-%E8%BF%9B%E7%A8%8B%E6%8E%A7%E5%88%B6%E5%9D%97%EF%BC%88PCB%EF%BC%89"><span class="nav-number">1.0.6.</span> <span class="nav-text">6. 进程控制块（PCB）</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E4%BB%80%E4%B9%88%E6%98%AF%E8%BF%9B%E7%A8%8B%E6%8E%A7%E5%88%B6%E5%9D%97"><span class="nav-number">1.0.6.0.1.</span> <span class="nav-text">什么是进程控制块</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E8%BF%9B%E7%A8%8B%E6%8E%A7%E5%88%B6%E7%9A%84%E4%BD%9C%E7%94%A8"><span class="nav-number">1.0.6.0.2.</span> <span class="nav-text">进程控制的作用</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%BF%9B%E7%A8%8B%E6%8E%A7%E5%88%B6%E5%9D%97%E4%B8%AD%E7%9A%84%E4%BF%A1%E6%81%AF"><span class="nav-number">1.0.6.1.</span> <span class="nav-text">进程控制块中的信息</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%BF%9B%E7%A8%8B%E6%8E%A7%E5%88%B6%E5%BF%AB%E7%9A%84%E7%BB%84%E7%BB%87%E6%96%B9%E5%BC%8F"><span class="nav-number">1.0.6.2.</span> <span class="nav-text">进程控制快的组织方式</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-%E8%BF%9B%E7%A8%8B%E6%8E%A7%E5%88%B6"><span class="nav-number">1.0.7.</span> <span class="nav-text">7.进程控制</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E5%86%85%E6%A0%B8"><span class="nav-number">1.0.7.0.1.</span> <span class="nav-text">操作系统内核</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E8%BF%9B%E7%A8%8B%E7%9A%84%E5%88%9B%E5%BB%BA"><span class="nav-number">1.0.7.0.2.</span> <span class="nav-text">进程的创建</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E8%BF%9B%E7%A8%8B%E7%9A%84%E5%88%9B%E5%BB%BA%E8%BF%87%E7%A8%8B"><span class="nav-number">1.0.7.0.3.</span> <span class="nav-text">进程的创建过程</span></a></li></ol></li></ol></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="yorn"
      src="/myblog/uploads/head.jpg">
  <p class="site-author-name" itemprop="name">yorn</p>
  <div class="site-description" itemprop="description">足够专注才能成功</div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/myblog/archives/">
          <span class="site-state-item-count">53</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/myblog/categories/">
        <span class="site-state-item-count">13</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/myblog/tags/">
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author site-overview-item animated">
      <span class="links-of-author-item">
        <a href="https://github.com/wang-chen1119" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;wang-chen1119" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:w1905989051@gmail.com" title="E-Mail → mailto:w1905989051@gmail.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>
  <div class="cc-license site-overview-item animated" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" class="cc-opacity" rel="noopener" target="_blank"><img src="https://cdnjs.cloudflare.com/ajax/libs/creativecommons-vocabulary/2020.11.3/assets/license_badges/small/by_nc_sa.svg" alt="Creative Commons"></a>
  </div>


  <div class="links-of-blogroll site-overview-item animated">
    <div class="links-of-blogroll-title"><i class="fa fa-globe fa-fw"></i>
      Links
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="https://blog.csdn.net/qq_51088445" title="https:&#x2F;&#x2F;blog.csdn.net&#x2F;qq_51088445" rel="noopener" target="_blank">CSDN</a>
        </li>
    </ul>
  </div>

        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

  <a href="https://github.com/wang-chen1119" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://wang-chen1119.gitee.io/myblog/2022/10/28/%E8%BF%9B%E7%A8%8B%E4%B8%8E%E7%A8%8B%E5%BA%8F/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/myblog/uploads/head.jpg">
      <meta itemprop="name" content="yorn">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Yorn's Notes">
      <meta itemprop="description" content="足够专注才能成功">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="进程与程序 | Yorn's Notes">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          进程与程序
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>
      

      <time title="创建时间：2022-10-28 13:57:30 / 修改时间：14:21:30" itemprop="dateCreated datePublished" datetime="2022-10-28T13:57:30+08:00">2022-10-28</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/myblog/categories/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" itemprop="url" rel="index"><span itemprop="name">操作系统</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>2.1k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>2 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h1 id="进程"><a href="#进程" class="headerlink" title="进程"></a>进程</h1><h3 id="1-为什么要引入进程"><a href="#1-为什么要引入进程" class="headerlink" title="1.为什么要引入进程"></a>1.为什么要引入进程</h3><hr>
<p>为了使程序在多道程序环境下能够并发执行，并对并发执行的程序加以控制和描述。</p>
<h3 id="2-进程的定义"><a href="#2-进程的定义" class="headerlink" title="2. 进程的定义"></a>2. 进程的定义</h3><p>进程是具有独立功能的可并发执行的程序在一个数据集上的运行过程，是系统进行资源分配和调度的基本单位。</p>
<h3 id="3-程序和进程的区别与联系"><a href="#3-程序和进程的区别与联系" class="headerlink" title="3.程序和进程的区别与联系"></a>3.程序和进程的区别与联系</h3><ol>
<li>进程是程序的一次执行是一个动态的概念而程序是完成某个功能的指令序列是一个静态的概念。</li>
</ol>
<p>​        进程可以说是程序的运行实体，没有程序也不会有进程。</p>
<ol start="2">
<li>进程是系统进程资源分配和调度的一个独立单位，程序不是。</li>
<li>程序可以作为一个软件资源长期保存而进程是程序的一次执行过程。进程是临时的、有生命的，他由创建而产生，完成任务后则被撤销。</li>
<li>进程是有结构的。   由程序、数据和进程控制块三部分组成。</li>
</ol>
<h3 id="4-进程的特征"><a href="#4-进程的特征" class="headerlink" title="4. 进程的特征"></a>4. 进程的特征</h3><ol>
<li>动态性: 进程是进程实体的执行过程，它的动态性表现在“由创建而产生，由调度而执行，因为得不到资源所以暂停执行，因为撤销而消亡”</li>
<li>并发性: 指多个进程实体同时存在于内存中，并且能在一段时间内同时运行。</li>
<li>独立性: 指进程实体是一个能独立运行的基本单位，同时也是系统中独立获得资源和独立调度的基本单位。 </li>
<li>异步性: 指进程按各自独立的、不可预知的速度向前推进，进程按异步方式运行</li>
<li>结构特征: 从结构上看进程实体由程序段、数据段及进程控制块三部分组成。</li>
</ol>
<h3 id="5-进程的基本状态和转换"><a href="#5-进程的基本状态和转换" class="headerlink" title="5. 进程的基本状态和转换"></a>5. 进程的基本状态和转换</h3><h4 id="进程的三种状态"><a href="#进程的三种状态" class="headerlink" title="进程的三种状态"></a>进程的三种状态</h4><ol>
<li>就绪状态 ：只差处理机资源，获得处理机资源即可运行</li>
<li>执行状态 ：进程已经获得了处理机，正在执行； 单处理机系统中只能有一个进程处于执行状态，多处理机系统中可能有多个进程处于执行状态。</li>
<li>阻塞状态 ：进程因为发生某种事件(如I&#x2F;O请求，申请缓存空间等)而暂停执行时的状态。</li>
</ol>
<h4 id="三种状态的转换"><a href="#三种状态的转换" class="headerlink" title="三种状态的转换"></a>三种状态的转换</h4><p><img src="https://image-1305623006.cos.ap-nanjing.myqcloud.com/img/202210281356812.png"></p>
<h4 id="进程的挂起状态"><a href="#进程的挂起状态" class="headerlink" title="进程的挂起状态"></a>进程的挂起状态</h4><p><strong>为什么需要挂起状态?</strong></p>
<p>挂起 —&gt;  将进程有内存调入到外存</p>
<ol>
<li>终端用户的需要 ：终端用户在自己的程序运行期间有发现可疑问题时，往往希望是自己的进程静止下来。</li>
<li>父进程的需要 ： 父进程常常需要考察和修改子进程或者当要协调各子进程间的活动时要挂起自己的子进程。</li>
<li>操作系统的需要 ：操作系统有时需要挂起某些进程，检查运行中资源的使用情况及进行记账，以便改善系统运行的性能。 </li>
<li>对换的需要 ：为了缓解内存紧张的情况，将内存中处于阻塞状态的进程换至外存上。</li>
<li>负荷条件的需要 ：当实时系统中的负荷较重可能影响到对实时任务的控制时，可由系统把一些不重要或不紧迫的程序挂起，以保证系统仍然能正常运行。</li>
</ol>
<p>引入挂起状态后的进程转换图</p>
<p><img src="https://image-1305623006.cos.ap-nanjing.myqcloud.com/img/202210281356799.png" alt="在这里插入图片描述"></p>
<h3 id="6-进程控制块（PCB）"><a href="#6-进程控制块（PCB）" class="headerlink" title="6. 进程控制块（PCB）"></a>6. 进程控制块（PCB）</h3><h5 id="什么是进程控制块"><a href="#什么是进程控制块" class="headerlink" title="什么是进程控制块"></a>什么是进程控制块</h5><p>进程控制块是进程实体的一部分，是操作系统中最重要的数据结构，记录了操作系统所需的、用于描述进程情况及控制进程运行所需的全部信息。</p>
<h5 id="进程控制的作用"><a href="#进程控制的作用" class="headerlink" title="进程控制的作用"></a>进程控制的作用</h5><ul>
<li><p>使一个多道程序环境下不能独立运行的程序(含数据),成为一个能独立运行的基本单位，一个能与其他进程并发执行的进程。</p>
</li>
<li><p>系统总是通过其PCB对进程进行控制</p>
</li>
<li><p>进程控制块PCB是进程存在的唯一标志。</p>
</li>
</ul>
<h4 id="进程控制块中的信息"><a href="#进程控制块中的信息" class="headerlink" title="进程控制块中的信息"></a>进程控制块中的信息</h4><ol>
<li>进程标识符信息</li>
</ol>
<ul>
<li>外部标识符 ： 由用户（进程）在访问该进程时使用，通常由创建者提供，由字母、数字组成。</li>
<li>内部标识符 ： 为方便系统使用而设置。 在所有的操作系统中都为每一个进程赋予一个唯一的整数作为内部标识符，通常就是一个进程的序号，为了描述进程的家族关系，还应设置父进程标识符及子进程标识符。</li>
</ul>
<ol start="2">
<li>处理机状态信息</li>
</ol>
<p>处理机状态主要是由处理机各种寄存器中的内容组成，处理机在运行时，许多信息都放在寄存器中。当处理机被中断时，这些信息被存在中断进程的PCB中，以便该进程重新执行时能从断点顺序执行。</p>
<p>存放处理机状态信息的寄存器包括</p>
<ul>
<li>通用寄存器</li>
<li>指令计数器</li>
<li>程序状态字PSW</li>
<li>用户栈指针</li>
</ul>
<ol start="3">
<li>进程调度信息</li>
</ol>
<ul>
<li>进程状态</li>
<li>进程优先级</li>
<li>进程调度所需要的其他信息</li>
<li>事件 ：指进程由执行状态变为阻塞状态所等待发生的事件，即阻塞原因</li>
</ul>
<ol start="4">
<li><p>进程控制信息</p>
</li>
<li><p>程序和数据的地址</p>
</li>
<li><p>进程同步和通信机制</p>
</li>
<li><p>资源清单 ： 是一张列出了除处理机外的进程所需的全部资源及已经分配到该进程的资源清单</p>
</li>
</ol>
<h4 id="进程控制快的组织方式"><a href="#进程控制快的组织方式" class="headerlink" title="进程控制快的组织方式"></a>进程控制快的组织方式</h4><ol>
<li>链接方式</li>
</ol>
<p>把具有相同状态的进程控制块PCB链接成一个队列</p>
<p><img src="https://image-1305623006.cos.ap-nanjing.myqcloud.com/img/202210281356927.png" alt="在这里插入图片描述"></p>
<ol start="2">
<li>索引方式</li>
</ol>
<p>系统根据所有进程的状态建立几张索引表</p>
<p><img src="https://image-1305623006.cos.ap-nanjing.myqcloud.com/img/202210281356778.png" alt="在这里插入图片描述"></p>
<h3 id="7-进程控制"><a href="#7-进程控制" class="headerlink" title="7.进程控制"></a>7.进程控制</h3><p>进程控制的主要任务是创建和撤销进程以及实现进程的状态转换。</p>
<h5 id="操作系统内核"><a href="#操作系统内核" class="headerlink" title="操作系统内核"></a>操作系统内核</h5><p>通常将一些与硬件紧密相关的模块，诸如中断处理程序、各种常用设备的驱动程序以及运行频率较高的模块，都安排在紧靠硬件的软件层次并使它们常驻内存，以便提高操作系统的运行效率，并对他们加以特殊的保护，这一部分成为操作系统的内核。</p>
<h5 id="进程的创建"><a href="#进程的创建" class="headerlink" title="进程的创建"></a>进程的创建</h5><p>为描述进程之间的创建关系引入“进程图”</p>
<p>进程图是用于描述进程家族关系的有向树。</p>
<p><strong>为什么要了解进程之间的家族关系？</strong></p>
<ul>
<li>进程可以继承父进程所拥有的资源</li>
<li>当子进程撤销时，应将父进程那里获得的资源全部还给父进程</li>
<li>当撤销父进程是，也必须同时撤销其所有的子进程</li>
</ul>
<p>引起进程创建的事件： 1. 用户登录 2.作业调度 3.提供服务 4. 应用请求</p>
<h5 id="进程的创建过程"><a href="#进程的创建过程" class="headerlink" title="进程的创建过程"></a>进程的创建过程</h5><ol>
<li>申请空白进程控制块</li>
<li>为新进程分配资源</li>
<li>初始化进程控制块</li>
<li>将新进程插入就绪队列</li>
</ol>
<p>引起进程终止的事件 1. 正常结束 2.异常结束 3.外界干预</p>
<p>引起进程阻塞和唤醒的事件（阻塞是主动行为，唤醒是被动行为）：1.请求系统服务2.启动某种操作3.新数据尚未到达4.无新工作可做</p>
<p><strong>学习资料 ： 操作系统 第四版 刘振鹏 张明 王煜著</strong></p>

    </div>

    
    
    

    <footer class="post-footer">
          

<div class="post-copyright">
<ul>
  <li class="post-copyright-author">
      <strong>本文作者： </strong>yorn
  </li>
  <li class="post-copyright-link">
      <strong>本文链接：</strong>
      <a href="http://wang-chen1119.gitee.io/myblog/2022/10/28/%E8%BF%9B%E7%A8%8B%E4%B8%8E%E7%A8%8B%E5%BA%8F/" title="进程与程序">http://wang-chen1119.gitee.io/myblog/2022/10/28/进程与程序/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>

          <div class="post-tags">
              <a href="/myblog/tags/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" rel="tag"><i class="fa fa-tag"></i> 操作系统</a>
              <a href="/myblog/tags/%E9%9D%A2%E7%BB%8F/" rel="tag"><i class="fa fa-tag"></i> 面经</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/myblog/2022/10/28/%E8%BF%9B%E7%A8%8B%E9%80%9A%E4%BF%A1%E4%B8%8E%E6%AD%BB%E9%94%81/" rel="prev" title="操作系统学习笔记(四):进程通信与死锁">
                  <i class="fa fa-chevron-left"></i> 操作系统学习笔记(四):进程通信与死锁
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/myblog/2022/10/28/%E6%96%87%E4%BB%B6%E7%AE%A1%E7%90%86/" rel="next" title="操作系统学习笔记(八):文件管理">
                  操作系统学习笔记(八):文件管理 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">yorn</span>
</div>

    </div>
  </footer>

  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/myblog/js/comments.js"></script><script src="/myblog/js/utils.js"></script><script src="/myblog/js/motion.js"></script><script src="/myblog/js/next-boot.js"></script><script src="/myblog/js/bookmark.js"></script>

  





  





<script src="/myblog/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
